/******************************************************************************
 * SAGE - Scalable Adaptive Graphics Environment
 *
 * Module: sage.h
 * Author : Byungil Jeong
 *
 * Copyright (C) 2004 Electronic Visualization Laboratory,
 * University of Illinois at Chicago
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either Version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser Public License along
 * with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Direct questions, comments etc about SAGE to bijeong@evl.uic.edu or 
 * http://www.evl.uic.edu/cavern/forum/
 *
 *****************************************************************************/

#ifndef _SAGE_H
#define _SAGE_H

#include "sageBase.h"

//#define BUFFERS_PER_INSTANCE 12
//#define MAX_FRAME_SIZE (1600*1200*4)

#define SAGE_VERSION "2.0"

// Message Start Point
#define FS_CORE_MESSAGE 0
#define SAGE_UI_TO_FSM 1000
#define APP_UI_TO_FSM 2000
#define APP_TO_FSM 3000
#define DISP_MESSAGE 10000
#define GRCV_MESSAGE 20000
#define SAIL_MESSAGE 30000
#define APP_MESSAGE 31000
#define FSM_TO_SAGE_UI 40000
#define FSM_TO_APP_UI  41000
#define BRIDGE_MESSAGE 50000
#define ARCV_MESSAGE 15000

// fsManager Messages
#define REG_APP  FS_CORE_MESSAGE + 1  // app_name block_width block_height pixel_size sync_mode
#define REG_GRCV FS_CORE_MESSAGE + 2
#define FS_APPDISP_KILLED  FS_CORE_MESSAGE + 3
#define FS_TIME_MSG FS_CORE_MESSAGE + 4
#define REG_ARCV FS_CORE_MESSAGE + 5
#define SYNC_INIT_ARCV FS_CORE_MESSAGE + 6

// UI to fsManager
#define SAGE_UI_REG   SAGE_UI_TO_FSM 
#define EXEC_APP 		 SAGE_UI_TO_FSM + 1
#define SHUTDOWN_APP  SAGE_UI_TO_FSM + 2
#define MOVE_WINDOW   SAGE_UI_TO_FSM + 3
#define RESIZE_WINDOW   SAGE_UI_TO_FSM + 4
#define PERF_INFO_REQ   SAGE_UI_TO_FSM + 5 
#define STOP_PERF_INFO  SAGE_UI_TO_FSM + 6
#define SAGE_BG_COLOR   SAGE_UI_TO_FSM + 7
#define SAGE_Z_VALUE		SAGE_UI_TO_FSM + 8
#define SAGE_ADMIN_CHECK	SAGE_UI_TO_FSM + 9
#define BRING_TO_FRONT		SAGE_UI_TO_FSM + 10
#define UPDATE_WIN_PROP		SAGE_UI_TO_FSM + 11
#define APP_FRAME_RATE		SAGE_UI_TO_FSM + 12
#define APP_PAUSE_INTV		SAGE_UI_TO_FSM + 13
#define SAGE_APP_SHARE		SAGE_UI_TO_FSM + 14
#define SAGE_FLIP_WINDOW	SAGE_UI_TO_FSM + 15
#define SAGE_SNAPSHOT       SAGE_UI_TO_FSM + 16

#define NETWORK_RESERVED   SAGE_UI_TO_FSM + 50

#define SAGE_SHUTDOWN 	SAGE_UI_TO_FSM + 100
#define STREAM_PAUSE		SAGE_UI_TO_FSM + 101
#define STREAM_RESUME	SAGE_UI_TO_FSM + 102

#define ADD_OBJECT		SAGE_UI_TO_FSM + 200
#define MOVE_OBJECT		SAGE_UI_TO_FSM + 201
#define REMOVE_OBJECT   SAGE_UI_TO_FSM + 202
#define OBJECT_MESSAGE  SAGE_UI_TO_FSM + 203

#define APP_UI_REG	APP_UI_TO_FSM

// displayManager Messages from SAIL
#define DISP_STREAM_INFO      DISP_MESSAGE
#define DISP_SAIL_PAUSED		DISP_MESSAGE + 2
#define DISP_SAIL_RESUME  		DISP_MESSAGE + 4
#define DISP_SAIL_PERF_RPT		DISP_MESSAGE + 5
#define NOTIFY_APP_SHUTDOWN 	DISP_MESSAGE + 6

// displayManager Messages from SAGE Receiver
#define DISP_START_STREAM		DISP_MESSAGE + 100
#define DISP_RCV_PAUSED			DISP_MESSAGE + 101
#define DISP_RCV_CONFIGURED  	DISP_MESSAGE + 102
#define DISP_DEPTH_CHANGED		DISP_MESSAGE + 103
#define DISP_RCV_FRATE_RPT		DISP_MESSAGE + 104
#define DISP_RCV_BANDWITH_RPT	DISP_MESSAGE + 105
#define DISP_RCV_RESUMED		DISP_MESSAGE + 106
#define DISP_CONNECTION_INFO  DISP_MESSAGE + 107
#define DISP_RCV_CLEARED		DISP_MESSAGE + 108

// gStreamRcv Messages
#define RCV_INIT					GRCV_MESSAGE
#define START_RECEIVERS  		GRCV_MESSAGE + 1
#define UPDATE_RECEIVERS 		GRCV_MESSAGE + 2
#define SHUTDOWN_RECEIVERS		GRCV_MESSAGE + 3
#define RCV_PAUSE_DISPLAY		GRCV_MESSAGE + 4
#define RCV_MASTER_PAUSE		GRCV_MESSAGE + 5
#define RCV_RESUME_DISPLAY		GRCV_MESSAGE + 6
#define RCV_CLEAR_DISPLAY		GRCV_MESSAGE + 7
#define RCV_CHANGE_BGCOLOR		GRCV_MESSAGE + 8
#define RCV_SHUTDOWN_APP		GRCV_MESSAGE + 9
#define RCV_CHANGE_DEPTH		GRCV_MESSAGE + 10
#define RCV_UPDATE_DISPLAY		GRCV_MESSAGE + 11
#define RCV_PERF_INFO_REQ		GRCV_MESSAGE + 12
#define RCV_PERF_INFO_STOP		GRCV_MESSAGE + 13
#define RCV_SAIL_CUR_FRAME		GRCV_MESSAGE + 14
#define RCV_INIT_CONNECTION	GRCV_MESSAGE + 15
#define RCV_SLAVE_PAUSE			GRCV_MESSAGE + 16
#define RCV_SETUP_BORDERS		GRCV_MESSAGE + 17
#define RCV_UPDATE_BORDERS 	GRCV_MESSAGE + 18
#define UPDATE_OBJECT_POSITION  GRCV_MESSAGE + 19
#define RCV_SNAPSHOT  GRCV_MESSAGE + 20
#define RCV_SYNC_INIT                   GRCV_MESSAGE + 21

// aStreamRcv Messages
#define ARCV_AUDIO_INIT                 ARCV_MESSAGE
#define ARCV_SYNC_INIT                  ARCV_MESSAGE + 1
#define ARCV_SHUTDOWN_APP               ARCV_MESSAGE + 2

// sage bridge messages
#define BRIDGE_REG_NODE			BRIDGE_MESSAGE
#define BRIDGE_SLAVE_INIT		BRIDGE_MESSAGE + 1
#define BRIDGE_SHUTDOWN			BRIDGE_MESSAGE + 2
#define BRIDGE_SHUTDOWN_APP	BRIDGE_MESSAGE + 3
#define BRIDGE_SLAVE_PERF		BRIDGE_MESSAGE + 4

#define BRIDGE_APP_REG			BRIDGE_MESSAGE + 6
#define BRIDGE_SLAVE_READY		BRIDGE_MESSAGE + 7
#define BRIDGE_STREAM_INIT		BRIDGE_MESSAGE + 8
#define BRIDGE_UI_REG			BRIDGE_MESSAGE + 9

// fsManager to UI
#define SAGE_STATUS      FSM_TO_SAGE_UI 
#define APP_INFO_RETURN  FSM_TO_SAGE_UI + 1
#define UI_PERF_INFO     FSM_TO_SAGE_UI + 2
#define UI_APP_SHUTDOWN		FSM_TO_SAGE_UI + 3
#define SAGE_DISPLAY_INFO  FSM_TO_SAGE_UI + 4
#define Z_VALUE_RETURN		FSM_TO_SAGE_UI + 5
#define APP_EXEC_CONFIG		FSM_TO_SAGE_UI + 6
#define UI_ADMIN_INFO		FSM_TO_SAGE_UI + 8
#define UI_MOVE_FAIL			FSM_TO_SAGE_UI + 15
#define UI_RESIZE_FAIL		FSM_TO_SAGE_UI + 16
#define UI_PERF_REQ_FAIL	FSM_TO_SAGE_UI + 17
#define UI_OBJECT_INFO		FSM_TO_SAGE_UI + 18

#define REQUEST_BANDWIDTH  FSM_TO_SAGE_UI + 100

#define POINTER_STATUS		FSM_TO_SAGE_UI + 200

#define APP_STATUS		FSM_TO_APP_UI

// SAIL Messages
#define SAIL_UI_CLIENT			SAIL_MESSAGE + 1
#define SAIL_SLAVE_REG			SAIL_MESSAGE + 2
#define SAIL_SHUTDOWN			SAIL_MESSAGE + 3
#define SAIL_STREAM_START		SAIL_MESSAGE + 4
#define SAIL_CONNECTED_TO_RCV	SAIL_MESSAGE + 5
#define SAIL_PERF_INFO			SAIL_MESSAGE + 6
#define SAIL_SEND_TIME_BLOCK	SAIL_MESSAGE + 7
#define SAIL_CONFIG_STREAM		SAIL_MESSAGE + 8

#define SAIL_INIT_STREAM		SAIL_MESSAGE + 100
#define SAIL_CONNECT_TO_RCV	SAIL_MESSAGE + 101
#define SAIL_INIT_MSG			SAIL_MESSAGE + 102
#define SAIL_PERF_INFO_REQ		SAIL_MESSAGE + 103
#define SAIL_PERF_INFO_STOP	SAIL_MESSAGE + 104
#define SAIL_FRAME_RATE			SAIL_MESSAGE + 105
#define SAIL_FLIP_WINDOW		SAIL_MESSAGE + 106
#define SAIL_CONNECT_TO_ARCV    SAIL_MESSAGE + 107

// App UI to APP
#define APP_KEY_INPUT		APP_MESSAGE
#define APP_KEY_SPECIAL		APP_MESSAGE + 1
#define APP_MOUSE_BUTTON	APP_MESSAGE + 2
#define APP_MOUSE_MOVE		APP_MESSAGE + 3
#define APP_SPECIFIC_MESSAGE APP_MESSAGE + 1000

// FSM to APP
#define APP_QUIT				APP_MESSAGE + 2000
#define APP_REFRESH_FRAME 	APP_MESSAGE + 2001

// APP Key Codes
#define APP_KEY_UP		101
#define APP_KEY_DOWN		102
#define APP_KEY_LEFT		103
#define APP_KEY_RIGHT	104
#define APP_KEY_PAGE_UP	105
#define APP_KEY_PAGE_DOWN	106
#define APP_KEY_HOME		107
#define APP_KEY_END		108
#define APP_KEY_INSERT	109

// APP Mouse Codes
#define APP_LEFT_BUTTON		201
#define APP_MIDDLE_BUTTON	202
#define APP_RIGHT_BUTTON	203
#define APP_BUTTON_UP		301
#define APP_BUTTON_DOWN		302

#endif
